package com.yunnuo.activiti.modeler.controller;

import com.yunnuo.system.comm.controller.BaseController;
import com.yunnuo.system.comm.util.page.TableDataInfo;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Model;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

/**
 * Created by w_weihf on 2018/9/20.
 */
@Controller
@RequestMapping("/activiti/model")
public class ModelerController extends BaseController {

    private String prefix = "activiti/model";

    @Autowired
    private RepositoryService repositoryService;


    @GetMapping()
    public String model()
    {
        return prefix + "/model";
    }
    /**
     * 获得所有的部署信息
     * @return
     */
    @RequiresPermissions("activiti:model:view")
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list()
    {
        //前台分页
        startPage();
        List<Model> modelList = repositoryService.createModelQuery().orderByCreateTime().desc().list();
        return getDataTable(modelList);
    }

}
